package cn.edu.scau.cmi.ema.domain;


import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.persistence.*;
import javax.xml.bind.annotation.*;
import cn.edu.scau.cmi.ema.domain.*;
import java.util.Set;
import com.alibaba.fastjson.annotation.JSONField;

@Entity
@NamedQueries({ @NamedQuery(name = "findAllEcharts", query = "select myEchart from Echart myEchart"),
		@NamedQuery(name = "findEchartByName", query = "select myEchart from Echart myEchart where myEchart.name = ?1"),
		@NamedQuery(name = "findEchartByNameContaining", query = "select myEchart from Echart myEchart where myEchart.name like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByEvent", query = "select myEchart from Echart myEchart where myEchart.event = ?1"),
		@NamedQuery(name = "findEchartByEventname", query = "select myEchart from Echart myEchart where myEchart.eventname = ?1"),
		@NamedQuery(name = "findEchartByEventnameContaining", query = "select myEchart from Echart myEchart where myEchart.eventname like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartBySourcecountry", query = "select myEchart from Echart myEchart where myEchart.sourcecountry = ?1"),
		@NamedQuery(name = "findEchartBySourcecountryContaining", query = "select myEchart from Echart myEchart where myEchart.sourcecountry like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartBySourceprovince", query = "select myEchart from Echart myEchart where myEchart.sourceprovince = ?1"),
		@NamedQuery(name = "findEchartBySourceprovinceContaining", query = "select myEchart from Echart myEchart where myEchart.sourceprovince like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartBySourcecity", query = "select myEchart from Echart myEchart where myEchart.sourcecity = ?1"),
		@NamedQuery(name = "findEchartBySourcecityContaining", query = "select myEchart from Echart myEchart where myEchart.sourcecity like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByDiscoverycountry", query = "select myEchart from Echart myEchart where myEchart.discoverycountry = ?1"),
		@NamedQuery(name = "findEchartByDiscoverycountryContaining", query = "select myEchart from Echart myEchart where myEchart.discoverycountry like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByDiscoveryprovince", query = "select myEchart from Echart myEchart where myEchart.discoveryprovince = ?1"),
		@NamedQuery(name = "findEchartByDiscoveryprovinceContaining", query = "select myEchart from Echart myEchart where myEchart.discoveryprovince like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByDiscoverycity", query = "select myEchart from Echart myEchart where myEchart.discoverycity = ?1"),
		@NamedQuery(name = "findEchartByDiscoverycityContaining", query = "select myEchart from Echart myEchart where myEchart.discoverycity like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByFoodtypename", query = "select myEchart from Echart myEchart where myEchart.foodtypename = ?1"),
		@NamedQuery(name = "findEchartByFoodtypenameContaining", query = "select myEchart from Echart myEchart where myEchart.foodtypename like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByFoodtype", query = "select myEchart from Echart myEchart where myEchart.foodtype = ?1"),
		@NamedQuery(name = "findEchartBySourceTime", query = "select myEchart from Echart myEchart where myEchart.sourceTime = ?1"),
		@NamedQuery(name = "findEchartByDiscoveryTime", query = "select myEchart from Echart myEchart where myEchart.discoveryTime = ?1"),
		@NamedQuery(name = "findEchartByDescription", query = "select myEchart from Echart myEchart where myEchart.description = ?1"),
		@NamedQuery(name = "findEchartByDescriptionContaining", query = "select myEchart from Echart myEchart where myEchart.description like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByAdultertype", query = "select myEchart from Echart myEchart where myEchart.adultertype = ?1"),
		@NamedQuery(name = "findEchartByAdultertypeContaining", query = "select myEchart from Echart myEchart where myEchart.adultertype like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByAdulterlink", query = "select myEchart from Echart myEchart where myEchart.adulterlink = ?1"),
		@NamedQuery(name = "findEchartByAdulterlinkContaining", query = "select myEchart from Echart myEchart where myEchart.adulterlink like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByFoodname", query = "select myEchart from Echart myEchart where myEchart.foodname = ?1"),
		@NamedQuery(name = "findEchartByFoodnameContaining", query = "select myEchart from Echart myEchart where myEchart.foodname like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartBySubject", query = "select myEchart from Echart myEchart where myEchart.subject = ?1"),
		@NamedQuery(name = "findEchartBySubjectContaining", query = "select myEchart from Echart myEchart where myEchart.subject like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByFoodmaintype", query = "select myEchart from Echart myEchart where myEchart.foodmaintype = ?1"),
		@NamedQuery(name = "findEchartByFoodmaintypeContaining", query = "select myEchart from Echart myEchart where myEchart.foodmaintype like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByFoodbatchfiller", query = "select myEchart from Echart myEchart where myEchart.foodbatchfiller = ?1"),
		@NamedQuery(name = "findEchartByFoodbatchfillerContaining", query = "select myEchart from Echart myEchart where myEchart.foodbatchfiller like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartByPunish", query = "select myEchart from Echart myEchart where myEchart.punish = ?1"),
		@NamedQuery(name = "findEchartByPunishContaining", query = "select myEchart from Echart myEchart where myEchart.punish like concat('%',?1,'%')"),
		@NamedQuery(name = "findEchartById", query = "select myEchart from Echart myEchart where myEchart.id = ?1"),
		@NamedQuery(name = "findEchartByPrimaryKey", query = "select myEchart from Echart myEchart where myEchart.id = ?1 "),
		@NamedQuery(name = "deleteEchartsByIds", query = "delete Echart where id in (?1)"),
		@NamedQuery(name = "findEchartsByIds", query = "select myEchart from Echart myEchart where myEchart.id in (?1)"),
		@NamedQuery(name = "findEchartByPhyscialPrimaryKey", query = "select myEchart from Echart myEchart where  myEchart.name = ?1"),
		@NamedQuery(name = "countEchartsByName", query = "select count(myEchart)  from Echart myEchart where myEchart.name like concat('%',?1,'%')") })
@Table(catalog = "ema", name = "echart")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "ema/cn/edu/scau/cmi/ema/domain", name = "Echart")
@XmlRootElement(namespace = "ema/cn/edu/scau/cmi/ema/domain")

public class Echart implements Serializable, Comparable<Echart> {

	private static final long serialVersionUID = 1L;

	@Column(name = "id", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@XmlElement
	Integer id;

	@Column(name = "name")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String name;

	@Column(name = "event")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer event;

	@Column(name = "eventname")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String eventname;

	@Column(name = "sourcecountry")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String sourcecountry;

	@Column(name = "sourceprovince")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String sourceprovince;

	@Column(name = "sourcecity")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String sourcecity;

	@Column(name = "discoverycountry")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String discoverycountry;

	@Column(name = "discoveryprovince")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String discoveryprovince;

	@Column(name = "discoverycity")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String discoverycity;

	@Column(name = "foodtypename")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String foodtypename;

	@Column(name = "foodtype")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer foodtype;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sourceTime")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar sourceTime;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "discoveryTime")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar discoveryTime;

	@Column(name = "description")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String description;

	@Column(name = "adultertype")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String adultertype;

	@Column(name = "adulterlink")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String adulterlink;

	@Column(name = "foodname")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String foodname;

	@Column(name = "subject")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String subject;

	@Column(name = "foodmaintype")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String foodmaintype;

	@Column(name = "foodbatchfiller")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String foodbatchfiller;

	@Column(name = "punish")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String punish;

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return this.id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return this.name;
	}

	public void setEvent(Integer event) {
		this.event = event;
	}

	public Integer getEvent() {
		return this.event;
	}

	public void setEventname(String eventname) {
		this.eventname = eventname;
	}

	public String getEventname() {
		return this.eventname;
	}

	public void setSourcecountry(String sourcecountry) {
		this.sourcecountry = sourcecountry;
	}

	public String getSourcecountry() {
		return this.sourcecountry;
	}

	public void setSourceprovince(String sourceprovince) {
		this.sourceprovince = sourceprovince;
	}

	public String getSourceprovince() {
		return this.sourceprovince;
	}

	public void setSourcecity(String sourcecity) {
		this.sourcecity = sourcecity;
	}

	public String getSourcecity() {
		return this.sourcecity;
	}

	public void setDiscoverycountry(String discoverycountry) {
		this.discoverycountry = discoverycountry;
	}

	public String getDiscoverycountry() {
		return this.discoverycountry;
	}

	public void setDiscoveryprovince(String discoveryprovince) {
		this.discoveryprovince = discoveryprovince;
	}

	public String getDiscoveryprovince() {
		return this.discoveryprovince;
	}

	public void setDiscoverycity(String discoverycity) {
		this.discoverycity = discoverycity;
	}

	public String getDiscoverycity() {
		return this.discoverycity;
	}

	public void setFoodtypename(String foodtypename) {
		this.foodtypename = foodtypename;
	}

	public String getFoodtypename() {
		return this.foodtypename;
	}

	public void setFoodtype(Integer foodtype) {
		this.foodtype = foodtype;
	}

	public Integer getFoodtype() {
		return this.foodtype;
	}

	public void setSourceTime(Calendar sourceTime) {
		this.sourceTime = sourceTime;
	}

	public Calendar getSourceTime() {
		return this.sourceTime;
	}

	public void setDiscoveryTime(Calendar discoveryTime) {
		this.discoveryTime = discoveryTime;
	}

	public Calendar getDiscoveryTime() {
		return this.discoveryTime;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return this.description;
	}

	public void setAdultertype(String adultertype) {
		this.adultertype = adultertype;
	}

	public String getAdultertype() {
		return this.adultertype;
	}

	public void setAdulterlink(String adulterlink) {
		this.adulterlink = adulterlink;
	}

	public String getAdulterlink() {
		return this.adulterlink;
	}

	public void setFoodname(String foodname) {
		this.foodname = foodname;
	}

	public String getFoodname() {
		return this.foodname;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getSubject() {
		return this.subject;
	}

	public void setFoodmaintype(String foodmaintype) {
		this.foodmaintype = foodmaintype;
	}

	public String getFoodmaintype() {
		return this.foodmaintype;
	}

	public void setFoodbatchfiller(String foodbatchfiller) {
		this.foodbatchfiller = foodbatchfiller;
	}

	public String getFoodbatchfiller() {
		return this.foodbatchfiller;
	}

	public void setPunish(String punish) {
		this.punish = punish;
	}

	public String getPunish() {
		return this.punish;
	}

	public void copy(Echart that) {

		setId(that.getId());

		setName(that.getName());
		setEvent(that.getEvent());
		setEventname(that.getEventname());
		setSourcecountry(that.getSourcecountry());
		setSourceprovince(that.getSourceprovince());
		setSourcecity(that.getSourcecity());
		setDiscoverycountry(that.getDiscoverycountry());
		setDiscoveryprovince(that.getDiscoveryprovince());
		setDiscoverycity(that.getDiscoverycity());
		setFoodtypename(that.getFoodtypename());
		setFoodtype(that.getFoodtype());
		setSourceTime(that.getSourceTime());
		setDiscoveryTime(that.getDiscoveryTime());
		setDescription(that.getDescription());
		setAdultertype(that.getAdultertype());
		setAdulterlink(that.getAdulterlink());
		setFoodname(that.getFoodname());
		setSubject(that.getSubject());
		setFoodmaintype(that.getFoodmaintype());
		setFoodbatchfiller(that.getFoodbatchfiller());
		setPunish(that.getPunish());

	}

	public Echart() {

	}

	@Override
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");

		buffer.append("name=[").append(name).append("] ");
		buffer.append("event=[").append(event).append("] ");
		buffer.append("eventname=[").append(eventname).append("] ");
		buffer.append("sourcecountry=[").append(sourcecountry).append("] ");
		buffer.append("sourceprovince=[").append(sourceprovince).append("] ");
		buffer.append("sourcecity=[").append(sourcecity).append("] ");
		buffer.append("discoverycountry=[").append(discoverycountry).append("] ");
		buffer.append("discoveryprovince=[").append(discoveryprovince).append("] ");
		buffer.append("discoverycity=[").append(discoverycity).append("] ");
		buffer.append("foodtypename=[").append(foodtypename).append("] ");
		buffer.append("foodtype=[").append(foodtype).append("] ");
		buffer.append("sourceTime=[").append(sourceTime).append("] ");
		buffer.append("discoveryTime=[").append(discoveryTime).append("] ");
		buffer.append("description=[").append(description).append("] ");
		buffer.append("adultertype=[").append(adultertype).append("] ");
		buffer.append("adulterlink=[").append(adulterlink).append("] ");
		buffer.append("foodname=[").append(foodname).append("] ");
		buffer.append("subject=[").append(subject).append("] ");
		buffer.append("foodmaintype=[").append(foodmaintype).append("] ");
		buffer.append("foodbatchfiller=[").append(foodbatchfiller).append("] ");
		buffer.append("punish=[").append(punish).append("] ");

		return buffer.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Echart))
			return false;
		Echart comparedEchart = (Echart) obj;
		if (!CheckPropertyEqual(this.name, comparedEchart.name)) {
			return false;
		}
		return true;
	}

	public static <T> boolean CheckPropertyEqual(T originProperty, T comparedProperty) {
		// 基本类型经过参数传递后会自动装箱
		String[] className = originProperty.getClass().getName().split("\\.");
		if (className[0].equals("java") && className[1].equals("math")) {
			return ((Comparable) originProperty).compareTo(comparedProperty) == 0 ? true : false;
		} else {
			return originProperty.equals(comparedProperty);
		}
	}

	@Override
	public int compareTo(Echart o) {
		if (this.getId() > o.getId()) {
			return 1;
		} else if (this.getId() == o.getId()) {
			return 0;
		} else {
			return -1;
		}

	}
}
